package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {
<#assign parmPK=""/>
<#assign sqlPK=""/>
<#assign eaitPK=""/>
<#list table.fields as field>
    <#if field.customMap.KEY??>
        <#if field.customMap.KEY == "PRI">
            <#if parmPK=="">
                <#assign parmPK += "String " + field.propertyName/>
                <#assign sqlPK += ".eq("+ entity + "::get" + field.propertyName?cap_first + ", " + field.propertyName + ")"/>
                <#assign eaitPK += ".eq("+ entity + "::get" + field.propertyName?cap_first + ", " + entity?uncap_first + ".get" + field.propertyName?cap_first + "())"/>
            <#else>
                <#assign parmPK += ", String " + field.propertyName/>
                <#assign sqlPK += "\n\t\t\t\t.eq("+ entity + "::get" + field.propertyName?cap_first + ", " + field.propertyName + ")"/>
                <#assign eaitPK += "\n\t\t\t\t.eq("+ entity + "::get" + field.propertyName?cap_first + ", " + entity?uncap_first + ".get" + field.propertyName?cap_first + "())"/>
            </#if>
        </#if>
    </#if>
</#list>

<#if parmPK??>
    @Override
    public ${entity} getByPk(${parmPK}) {
        LambdaQueryWrapper<${entity}> lambda = new QueryWrapper<${entity}>().lambda()
                ${sqlPK};
        return baseMapper.selectOne(lambda);
    }

    @Override
    public boolean updateByPk(${entity} ${entity?uncap_first}) {
        LambdaQueryWrapper<${entity}> lambda = new QueryWrapper<${entity}>().lambda()
                ${eaitPK};
        return super.update(${entity?uncap_first}, lambda);
    }

    @Override
    public boolean removeByPk(${parmPK}) {
        LambdaQueryWrapper<${entity}> lambda = new QueryWrapper<${entity}>().lambda()
                ${sqlPK};
        return super.remove(lambda);
    }
</#if>

}
</#if>